From 553fe1c71082b040e9f9667ad3e99acdb33990b2 Mon Sep 17 00:00:00 2001
From: Artrix <sefu786@outlook.com>
Date: Fri, 5 Jan 2024 05:12:52 -0800
Subject: feat: Implement a way to review/rate anime (#108)

* Make details cover lead back to anime page

* Make 'markProgress' use object instead of param list

* Import Link

* Implement Rate modal

* Pass session into useAniList

Co-authored-by: Factiven <factiven.org@gmail.com>

* Reimplement using markComplete & add toast for failure

* redefined ratemodal

* fix: home page client error

* update version

---------

Co-authored-by: Factiven <factiven.org@gmail.com>
---
 pages/api/v2/episode/[id].tsx | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

(limited to 'pages/api/v2/episode/[id].tsx')

diff --git a/pages/api/v2/episode/[id].tsx b/pages/api/v2/episode/[id].tsx
index b646126..ddf5635 100644
--- a/pages/api/v2/episode/[id].tsx
+++ b/pages/api/v2/episode/[id].tsx
@@ -139,10 +139,6 @@ async function fetchAnify(id?: string) {
 
 async function fetchCoverImage(id: string, available = false) {
   try {
-    if (!process.env.API_KEY) {
-      return [];
-    }
-
     if (available) {
       return null;
     }
@@ -171,10 +167,10 @@ export default async function handler(
 ) {
   const { id, releasing = "false", dub = false, refresh = null } = req.query;
 
-  // if releasing is true then cache for 1 hour, if it false cache for 1 month;
+  // if releasing is true then cache for 3 hour, if it false cache for 1 month;
   let cacheTime = null;
   if (releasing === "true") {
-    cacheTime = 60 * 60; // 1 hour
+    cacheTime = 60 * 60 * 3; // 3 hours
   } else if (releasing === "false") {
     cacheTime = 60 * 60 * 24 * 30; // 1 month
   }
@@ -210,7 +206,7 @@ export default async function handler(
       meta = null;
     }
 
-    if (refresh) {
+    if (refresh !== null) {
       await redis.del(`episode:${id}`);
     } else {
       cached = await redis.get(`episode:${id}`);
@@ -262,12 +258,6 @@ export default async function handler(
       fetchCoverImage(id, meta),
     ]);
 
-    // const hasImage = consumet.map((i) =>
-    //   i.episodes?.sub?.some(
-    //     (e) => e.img !== null || !e.img.includes("https://s4.anilist.co/")
-    //   )
-    // );
-
     let subDub = "sub";
     if (dub) {
       subDub = "dub";
-- 
cgit v1.2.3

